package com.jxw.launcher.util;

import android.app.Dialog;
import android.content.Context;
import android.content.res.Resources;
import android.media.MediaPlayer;
import android.os.Build;
import android.text.InputFilter;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.RelativeSizeSpan;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import cn.qqtheme.framework.adapter.FileAdapter;
import com.jxw.constant.Constant;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

/* loaded from: classes.dex */
public class Util {
    private static final long MIN_CLICK_TIME = 2000;
    public static String URL = "http://api.test.jiumentongbu.com:16378/api/appmarket/new/extensionApkList?extraIsbn=bbgb&positionId=1";
    private static long lastClickTime;
    public static String HOST = Constant.REGISTER_URL_HEADER;
    public static String API_HOST = Constant.PLATFORM_URL_HEADER;
    public static String EXTENSION_APK_LIST = API_HOST + "/api/appmarket/new/extensionApkList?";
    public static String GK_APPLIST = Constant.PLATFORM_URL_HEADER + "/api/jxwdevice/applist";
    public static String DOWNLOAD_NUM = API_HOST + "/api/appmarket/incDownloadNum?";
    public static final String CHECK_REGIST_URL = HOST + "/platform/checkregister?";
    public static String APP_MARK_ADD = API_HOST + "/api/appmarketinfo/add?";
    public static final String ALARM_URL = HOST + "/platform/alarm?";
    public static final String CHECK_SERIES_URL = HOST + "/platform/checkseries?";
    private static MediaPlayer mediaPlayer = null;
    private static SimpleDateFormat sf = null;

    public static String getSerialNumber(Context context) {
        String str = SystemPropertiesProxy.get(context, "ro.serialno");
        if (str == null || str.equals("") || str.equals("unknown")) {
            if (Build.VERSION.SDK_INT >= 26) {
                String serial = Build.getSerial();
                return (serial == null || serial.equals("") || serial.equals("unknown")) ? Build.SERIAL : serial;
            }
            return Build.SERIAL;
        }
        return str;
    }

    public static int dpToPx(Context context, float f) {
        return (int) ((f * context.getApplicationContext().getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static void setEditTextInhibitInputSpeChat(EditText editText) {
        editText.setFilters(new InputFilter[]{new InputFilter() { // from class: com.jxw.launcher.util.Util.1
            @Override // android.text.InputFilter
            public CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
                if (Pattern.compile("[` ~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]").matcher(charSequence.toString()).find()) {
                    return "";
                }
                return null;
            }
        }});
    }

    public static int getStatusHeight(Context context) {
        Resources resources = context.getResources();
        return resources.getDimensionPixelSize(resources.getIdentifier("status_bar_height", "dimen", "android"));
    }

    public static int[] getScreenWH(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) context.getApplicationContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        return new int[]{displayMetrics.widthPixels, displayMetrics.heightPixels};
    }

    public static void hide(Dialog dialog) {
        View currentFocus = dialog.getCurrentFocus();
        if (currentFocus instanceof TextView) {
            ((InputMethodManager) dialog.getContext().getSystemService("input_method")).hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
        }
    }

    public static void showSound(int i, Context context) {
        mediaPlayer = MediaPlayer.create(context, i);
        mediaPlayer.setVolume(0.8f, 0.8f);
        mediaPlayer.start();
    }

    public static SpannableStringBuilder setNumColor(String str) {
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
        for (int i = 0; i < str.length(); i++) {
            char charAt = str.charAt(i);
            if (charAt >= '0' && charAt <= '9') {
                spannableStringBuilder.setSpan(new RelativeSizeSpan(2.0f), i, i + 1, 33);
            }
        }
        return spannableStringBuilder;
    }

    public static String getDateToString(long j) {
        Date date = new Date(j);
        sf = new SimpleDateFormat("yyyy-MM-dd");
        return sf.format(date);
    }

    public static Long getTimestamp(String str) {
        try {
            return Long.valueOf(new SimpleDateFormat("yyyy-MM-dd").parse(str).getTime());
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String getPrintSize(long j) {
        if (j < 1024) {
            return String.valueOf(j) + "B";
        }
        long j2 = j / 1024;
        if (j2 < 1024) {
            return String.valueOf(j2) + "KB";
        }
        long j3 = j2 / 1024;
        if (j3 < 1024) {
            long j4 = j3 * 100;
            return String.valueOf(j4 / 100) + FileAdapter.DIR_ROOT + String.valueOf(j4 % 100) + "MB";
        }
        long j5 = (j3 * 100) / 1024;
        return String.valueOf(j5 / 100) + FileAdapter.DIR_ROOT + String.valueOf(j5 % 100) + "GB";
    }

    public static String stringToMD5(String str) {
        try {
            byte[] digest = MessageDigest.getInstance("MD5").digest(str.getBytes("UTF-8"));
            StringBuilder sb = new StringBuilder(digest.length * 2);
            for (byte b : digest) {
                int i = b & 255;
                if (i < 16) {
                    sb.append("0");
                }
                sb.append(Integer.toHexString(i));
            }
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        } catch (NoSuchAlgorithmException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public static boolean isFastClick() {
        long currentTimeMillis = System.currentTimeMillis();
        boolean z = currentTimeMillis - lastClickTime >= 2000;
        lastClickTime = currentTimeMillis;
        return z;
    }
}
